/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.ucv.convertidores.gestionarea;


import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import pe.edu.ucv.daos.FindentityDAO;
import pe.edu.ucv.entidades.Area;

/**
 *
 * @author Administrator
 */
@Stateless
@LocalBean
@FacesConverter(forClass=Area.class,value="areaconverter")
public class Areaconverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        FindentityDAO findDAO=new FindentityDAO();
        Integer id=Integer.parseInt(value);
        Area area=findDAO.findArea(id);
        return area;
        
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        
        Area area =(Area)value;
        return String.valueOf(area.getId());
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
}
